﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace Kinect.Framework.Controls
{
    public class KinectManipulation : DependencyObject
    {
        #region IsSelectable Property
        public static readonly DependencyProperty IsSelectableProperty = DependencyProperty.RegisterAttached(
            "IsSelectable",
            typeof(Boolean),
            typeof(KinectManipulation),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)
            );
        public static void SetIsSelectable(UIElement element, Boolean value)
        {
            element.SetValue(IsSelectableProperty, value);
        }
        public static Boolean GetIsSelectable(UIElement element)
        {
            return (Boolean)element.GetValue(IsSelectableProperty);
        }
        #endregion

        #region Click event
        public static readonly RoutedEvent ClickEvent = EventManager.RegisterRoutedEvent("Click", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(KinectManipulation));
        public static void AddClickHandler(DependencyObject d, RoutedEventHandler handler)
        {
            UIElement uie = d as UIElement;
            if (uie != null)
            {
                uie.AddHandler(KinectManipulation.ClickEvent, handler);
            }
        }
        public static void RemoveClickHandler(DependencyObject d, RoutedEventHandler handler)
        {
            UIElement uie = d as UIElement;
            if (uie != null)
            {
                uie.RemoveHandler(KinectManipulation.ClickEvent, handler);
            }
        }
        #endregion

        public static bool IsDesignTime
        {
            get
            {
                return (Application.Current == null) || (Application.Current.GetType() == typeof(Application));
            }
        }
    }

}
